﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Admin_ThemTaiKhoan : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    AccessData acc = new AccessData();
    protected void btnThem_Click(object sender, EventArgs e)
    {
        string username = txtUserName.Text;
        string password = txtPassword.Text.Trim();
        string email = txtEmail.Text.Trim();
        string hoten = txtHoTen.Text.Trim();
        int quyen = Convert.ToInt32(drlQuyen.SelectedValue);
        string date = DateTime.Now.ToShortDateString();
        int status=-1 ;
        //lam sao trong nay no kiem tra dc
        if (cbKichHoat.Checked == true)
            status = 1;
        int kq = acc.getValueProcedure("sp_KiemTraUser", username);

        if (kq == 1)
            WebMsgBox.Show("Tài Khoản đã tồn tại");
        else
            try
            {
                acc.ExecSProcedure("sp_ThemUser", username, password, quyen, hoten, email, status, date);
                WebMsgBox.Show("Thêm thành công");
            }
            catch
            {
                WebMsgBox.Show("Email: " + email + "đã tồn tại !");
            }
        
    }
}